import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom'
import loadable from '@loadable/component'
// import Login from '../views/login/index'
// import Admin from '../views/admin/index'
const Login = loadable(() => import('../views/login/index'))
// const Admin = loadable(() => import('../views/admin/index'))
const CartHome = loadable(() => import('../views/cart/home'))
const CartDetail = loadable(() => import('../views/cart/detail'))
const Cart = loadable(() => import('../views/cart/cart'))

const BasicLayout = loadable(() => import('../layouts/BasicLayout'))
const BlankLayout = loadable(() => import('../layouts/BlankLayout'))

const RouterView = () => {
  return <Switch>

    <Route path="/login" render={() => {
      return <Switch>
        <BlankLayout>
           <Route path='/' component={Login}></Route>
        </BlankLayout>
      </Switch>
    }}></Route>

    <Route path="/" render={() => {
      return <Switch>
        <BasicLayout>

           <Route path='/home' component={CartHome}></Route>
           <Route path='/cart' component={Cart}></Route>
           <Route path='/detail' component={CartDetail}></Route>
        </BasicLayout>
      </Switch>
    }}></Route>

    <Redirect from='/' to='/login' />
  </Switch>
}

export default RouterView;

